package cn.smdq.ch.upms.admin.pay.channel;

import cn.smdq.ch.common.core.exception.BaseException;
import cn.smdq.ch.upms.admin.pay.channel.param.PrePayResponse;
import cn.smdq.ch.upms.admin.pay.channel.support.AliPayMobileWapChannel;
import cn.smdq.ch.upms.admin.pay.type.PayType;
import com.alibaba.fastjson.JSONObject;

/**
 * @author shuimodanqing
 * create at:  2019/1/29  1:58 PM
 * @description 根据不同支付渠道选择不同的支付方式
 */
public class RoutePayChannel implements PayChannel {

    private PayChannel delegate;

    public RoutePayChannel(PayType payType, JSONObject requestParam) {
        switch (payType) {
            case ALI_PAY_WAP:
                delegate = new AliPayMobileWapChannel(requestParam);
                break;
            default:
                throw new BaseException("暂无支付渠道！");
        }
    }

    @Override
    public PrePayResponse pay(PayType payType) {
        return this.delegate.pay(payType);
    }
}
